Skip to content

nordic: use portable IRQ pending API in drivers/socs - #117388

Open
nashif wants to merge 7 commits into
zephyrproject-rtos:mainfrom
nashif:topic/irq-pending/nordic
Open

nordic: use portable IRQ pending API in drivers/socs#117388
nashif wants to merge 7 commits into
zephyrproject-rtos:mainfrom
nashif:topic/irq-pending/nordic

Conversation

@nashif

@nashif nashif commented Aug 26, 2026

Copy link
Copy Markdown
Member
  • drivers: timer: nrf_rtc: use portable IRQ pending API
  • drivers: serial: nrfx_uart: use portable IRQ pending API
  • drivers: usb: nrf: use portable IRQ pending API
  • drivers: entropy: nrf5: use portable IRQ pending API
  • Bluetooth: controller: nrf5: use portable IRQ pending API
  • boards: qemu: cortex_m0: use portable IRQ pending API

edit by @aescolar
Related

This test turns on ARM_CUSTOM_INTERRUPT_CONTROLLER on every Cortex-M
platform, which routes the architecture IRQ operations to z_soc_irq_*()
hooks that the test implements on top of the NVIC. It provides the
enable, disable, is_enabled, priority, EOI and get_active hooks but not
the pending-state ones, and since ARCH_HAS_IRQ_PENDING_OPS is only
selected for a plain NVIC, k_irq_*_pending() disappears in this
configuration.

Drivers that are always part of the image -- system timers and console
UARTs -- and that use k_irq_clear_pending() therefore fail to build
here, for example mchp_xec_rtos_timer.c on mec15xxevb_assy6853:

  error: implicit declaration of function 'k_irq_clear_pending'

Select ARCH_HAS_IRQ_PENDING_OPS from the test's Kconfig and add NVIC
backed z_soc_irq_clear_pending(), z_soc_irq_set_pending() and
z_soc_irq_is_pending(), the same way the test already wraps the NVIC
for the other hooks. This is exactly what an SoC with a custom
controller that can report and clear pending state is expected to do.

Built with tests/arch/arm/arm_custom_interrupt on
mec15xxevb_assy6853/mec1501_hsz, nrf52840dk/nrf52840, da1469x_dk_pro,
apollo3_evb, rts5912_evb and mps2/an385 together with the k_irq_*
driver conversions.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Comment on lines +66 to +67
#include <zephyr/irq.h>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <zephyr/irq.h>

@aescolar aescolar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bug on posix_sw_is_pending_IRQ() (pending != pending & not masked)
The naming of the new functions is off.
The native sim irq handler is not limited to 64 interrupts, better to not limit it now.
This would break out of tree boards, but we don't have to.
Why not add ARCH_HAS_IRQ_GET_ACTIVE also (the underlying API was there already)
Circumstantial: The posix arch and native sim are not nordic boards (even if I work today for nordic), so this should be a separate PR.
Instead of iterating here clarifying the issues, I just queued another version without all these in:

#117448

@nashif

nashif commented Aug 26, 2026

Copy link
Copy Markdown
Member Author

Circumstantial: The posix arch and native sim are not nordic boards (even if I work today for nordic), so this should be a separate PR.

right, I actually had another branch preped for posix_arch, but missed pushing it on its own :| topic/irq-pending/arch-posix, added here because I hot some depenendy with nrf_bsim I guess.

nashif added 6 commits August 26, 2026 06:53
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending(). The portable API is backed by
the NVIC on the Nordic hardware targets and by the POSIX-arch board
interface on the simulated bsim targets, so the CMSIS emulation layer
is no longer involved.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending(). The portable API is backed by
the NVIC on the Nordic hardware targets and by the POSIX-arch board
interface on the simulated bsim targets, so the CMSIS emulation layer
is no longer involved.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending(). The portable API is backed by
the NVIC on the Nordic hardware targets and by the POSIX-arch board
interface on the simulated bsim targets, so the CMSIS emulation layer
is no longer involved.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending(). The portable API is backed by
the NVIC on the Nordic hardware targets and by the POSIX-arch board
interface on the simulated bsim targets, so the CMSIS emulation layer
is no longer involved.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending(). The portable API is backed by
the NVIC on the Nordic hardware targets and by the POSIX-arch board
interface on the simulated bsim targets, so the CMSIS emulation layer
is no longer involved.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending(). The portable API is backed by
the NVIC on the Nordic hardware targets and by the POSIX-arch board
interface on the simulated bsim targets, so the CMSIS emulation layer
is no longer involved.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
@nashif
nashif force-pushed the topic/irq-pending/nordic branch from d0340d5 to fbc5566 Compare August 26, 2026 10:53
@zephyrbot zephyrbot added area: Tests Issues related to a particular existing or missing test area: UART Universal Asynchronous Receiver-Transmitter labels Aug 26, 2026
@nashif

nashif commented Aug 26, 2026

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Architectures area: ARM ARM (32-bit) Architecture area: Bluetooth Controller area: Bluetooth area: Boards/SoCs area: Crypto / RNG area: native port Host native arch port (native_sim) area: Tests Issues related to a particular existing or missing test area: Timer Timer area: UART Universal Asynchronous Receiver-Transmitter area: USB Universal Serial Bus platform: nRF Nordic nRFx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants